cmake_minimum_required(VERSION 2.6)

project(BBN)

if(UNIX)
	set(BBN_INSTALL_BY_DEFAULT ON)
else(UNIX)
	set(BBN_INSTALL_BY_DEFAULT OFF)
endif(UNIX)

option(BBN_INSTALL "Install Beep-Boop Nova libs, includes, and CMake scripts" ${BBN_INSTALL_BY_DEFAULT})
option(BBN_BUILD_SHARED "Build BBN shared libraries" ON)
option(BBN_BUILD_STATIC "Build BBN static libraries" OFF)
option(BBN_BUILD_DEMOS "Build BBN demo programs" ON)
option(BBN_BUILD_TOOLS "Build BBN tool programs" ON)
option(BBN_USE_OPENGL "Use OpenGL backend" ON)
option(BBN_USE_OPENGLES "Use OpenGLES backend" OFF)
option(BBN_USE_OPENGLv1 "Restrict function calls to those compatible with OpenGL version 1.1 with extensions" OFF)

set(BBN_VERSION 0.0.1)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/CMakeTests)



find_package(SDL2_gpu REQUIRED)

if ( NOT SDL2_gpu_FOUND )
   message ( FATAL_ERROR "SDL2_gpu not found!" )
endif ( NOT SDL2_gpu_FOUND )

include_directories(${SDL2_gpu_INCLUDE_DIR})
link_libraries(${SDL2_gpu_LIBRARY})



find_package(SDL2_ttf REQUIRED)

if ( NOT SDL2_ttf_FOUND )
   message ( FATAL_ERROR "SDL2_ttf not found!" )
endif ( NOT SDL2_ttf_FOUND )

include_directories(${SDL2_ttf_INCLUDE_DIR})
link_libraries(${SDL2_ttf_LIBRARY})



find_package(SDL2 REQUIRED)

if ( NOT SDL2_FOUND )
   message ( FATAL_ERROR "SDL2 not found!" )
endif ( NOT SDL2_FOUND )


include_directories(${SDL2_INCLUDE_DIR})
link_libraries(${SDL2MAIN_LIBRARY} ${SDL2_LIBRARY})

# Find the package for OpenGL or OpenGLES
if (BBN_USE_OPENGL)

	find_package(OpenGL REQUIRED)
	include_directories(${OPENGL_INCLUDE_DIR})
	link_libraries (${OPENGL_LIBRARIES})
	add_definitions("-DBBN_USE_OPENGL")
	
	if (BBN_USE_OPENGLv1)
		add_definitions("-DBBN_USE_OPENGLv1")
	endif (BBN_USE_OPENGLv1)
	
else (BBN_USE_OPENGL)

	if (BBN_USE_OPENGLES)

		find_package(OpenGLES REQUIRED)
		include_directories(${OPENGLES_INCLUDE_DIR})
		link_libraries (${OPENGLES_LIBRARIES})
		add_definitions("-DBBN_USE_OPENGLES")
		
	endif (BBN_USE_OPENGLES)

endif (BBN_USE_OPENGL)



# Make local includes look in the right places
include_directories(BBN)


add_definitions("-g -Wall -pedantic")

# Build the BBN library.
add_subdirectory(BBN)

# Build the demos
if(BBN_BUILD_DEMOS)
  add_subdirectory(demos)
endif(BBN_BUILD_DEMOS)
